From 944fa80ad339e452041b83f6a1325431f49f7822 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 15 Sep 1994 03:21:56 +0000 Subject: [PATCH] (forward-page): If we find a match that ends where we started searching, look for another one. --- lisp/textmodes/page.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lisp/textmodes/page.el b/lisp/textmodes/page.el index dc86e6997be..d84d7f5a07b 100644 --- a/lisp/textmodes/page.el +++ b/lisp/textmodes/page.el @@ -43,9 +43,18 @@ A page boundary is any line whose beginning matches the regexp (setq count (1- count))) (while (and (< count 0) (not (bobp))) (forward-char -1) - (if (re-search-backward page-delimiter nil t) - (goto-char (match-end 0)) - (goto-char (point-min))) + (let (result (end (point))) + ;; If we find a match that ends where we started searching, + ;; look for another one. + (while (and (setq result (re-search-backward page-delimiter nil t)) + (= (match-end 0) end)) + ;; Just search again. + ) + (if result + ;; We found one--move to the end of it. + (goto-char (match-end 0)) + ;; We found nothing--go to beg of buffer. + (goto-char (point-min)))) (setq count (1+ count)))) (defun backward-page (&optional count) -- 2.30.2